package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.RolePermission;
import cn.wolfcode.car.mapper.RolePermissionMapper;
import cn.wolfcode.car.qo.RolePermissionQueryObject;
import cn.wolfcode.car.service.IRolePermissionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RolePermissionServiceImpl implements IRolePermissionService {
    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public int delete(Long id) {
        return 0;
    }

    @Override
    public int save(RolePermission record) {
        return rolePermissionMapper.insert(record);
    }

    @Override
    public RolePermission get(Long id) {
        return null;
    }

    @Override
    public PageInfo<RolePermission> list(RolePermissionQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<RolePermission> list = rolePermissionMapper.selectForQo(qo);
        return new PageInfo<>(list);
    }

    @Override
    public int update(RolePermission record) {
        return 0;
    }

    @Override
    public List<RolePermission> listAll() {
        return rolePermissionMapper.selectAll();
    }

    @Override
    public List<RolePermission> listForLeftJoin() {
        return rolePermissionMapper.listForLeftJoin();
    }

    @Override
    public void deleteByRoleId(Long id) {
        rolePermissionMapper.deleteByRoleId(id);
    }
}
